var e = require("../../../../@babel/runtime/helpers/typeof"), a = getApp();

Page({
    data: {
        language: "",
        froze: 0,
        love_name: "",
        transfer_status: !1,
        trading_status: !1,
        recharge: 0,
        withdraw_status: !1,
        recharge_status: !1,
        title: "",
        show: !1,
        sell_value: "",
        sell_id: "",
        poundage: 0,
        trading_limit: 0,
        trading_fold: 0,
        usable: 0,
        ios_virtual_pay: !1,
        speed_pool_enable: 0,
        froze_name: "",
        usable_name: "",
        redpack_enable: !1,
        activation_record: !1,
        withdrawData: {
            day: 0,
            disable: 0,
            day_msg: "",
            language: "提现"
        },
        love_cycle_reward: "disabled",
        transfer_point_status: "",
        pointKey: "",
        love_queue: "",
        credit_validity_at: 0,
        love_queue_length: 0,
        change_integral: {},
        integral: "消费积分",
        active_froze: "",
        show_usable: !1
    },
    onLoad: function(e) {
        this.checkrouter();
        try {
            var t = wx.getStorageSync("ios_virtual_pay");
            t && this.setData({
                ios_virtual_pay: t
            });
        } catch (e) {
            console.log(e);
        }
        if (e.scene) {
            var o = decodeURIComponent(e.scene);
            if (o) {
                var n = [];
                n = o.split(",");
                for (var s = 0; s < n.length; s++) {
                    var i;
                    "mid" == (i = n[s].split("="))[0] && a._setMid(i[1]);
                }
            }
        }
    },
    checkrouter: function() {
        try {
            var a = function() {
                for (var e = wx.getStorageSync("yz_basic_info"), a = e.popularize_page.mini.vue_route, t = 0; t < a.length; t++) if ("love_index" == a[t]) return console.log(e.popularize_page.mini.mini_url + "跳转的路径"), 
                wx.showToast({
                    title: "未开启推广权限",
                    duration: 2e3,
                    icon: "none",
                    success: function() {
                        setTimeout(function() {
                            wx.redirectTo({
                                url: e.popularize_page.mini.mini_url
                            });
                        }, 1e3);
                    }
                }), {
                    v: void 0
                };
            }();
            if ("object" === e(a)) return a.v;
        } catch (e) {
            console.log(e);
        }
    },
    onReady: function() {
        var e = wx.getStorageSync("langIndex");
        this.setData({
            language: e.en
        });
    },
    onShow: function() {
        this.getyz_basic_info(), this.getBalance();
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    getyz_basic_info: function() {
        try {
            var e = wx.getStorageSync("yz_basic_info");
            e && this.setData({
                integral: e.integral
            });
        } catch (e) {}
    },
    makeTransfer: function(e) {
        if ("donate" != e.currentTarget.dataset.url) {
            var t = a.getNetAddresss("plugin.love.Frontend.Controllers.page.authentication");
            a._getNetWork({
                url: t,
                success: function(e) {
                    1 === e.data.result && e.data.data.flag ? wx.navigateTo({
                        url: "/packageB/member/love/love_transfer/love_transfer"
                    }) : a.tips(e.data.msg);
                },
                fail: function(e) {
                    console.log(e);
                }
            });
        } else wx.navigateTo({
            url: "/packageB/member/love/love_transfer/love_transfer?key=donate"
        });
    },
    tapPoster: function() {
        var e = this, t = a.getNetAddresss("plugin.love.Frontend.Controllers.poster");
        a._postNetWork({
            url: t,
            success: function(a) {
                var t = a.data.data;
                1 === a.data.result ? e.setData({
                    posterImg: t,
                    showPoster: !0
                }) : wx.showToast({
                    title: a.data.msg,
                    icon: "none"
                });
            },
            fail: function(e) {
                console.log(e);
            }
        });
    },
    onPosterClose: function() {
        this.setData({
            showPoster: !1
        });
    },
    saveImg: function() {
        wx.previewImage({
            current: this.data.posterImg,
            urls: [ this.data.posterImg ]
        });
    },
    getBalance: function() {
        var e = this, t = this, o = a.getNetAddresss("plugin.love.Frontend.Controllers.page.index");
        a._getNetWork({
            url: o,
            success: function(o) {
                var n = o.data, s = wx.getStorageSync("mailLanguage");
                s && n.data.withdraw_date && (s = JSON.parse(s), n.data.withdraw_date.language = s.income.name_of_withdrawal), 
                1 === n.result ? (n.data.withdraw_date && e.setData({
                    withdrawData: n.data.withdraw_date
                }), console.log(n.data.love_queue, "sssssssss"), e.setData({
                    transfer_point_status: n.data.transfer_point_status,
                    pointKey: n.data.point_name,
                    froze: n.data.froze,
                    love_name: n.data.love_name,
                    title: n.data.love_name,
                    usable: n.data.usable,
                    transfer_status: n.data.transfer_status,
                    trading_status: n.data.trading_set.trading,
                    no_recharge: n.data.no_recharge,
                    withdraw_status: n.data.withdraw_status,
                    recharge_status: n.data.recharge_status,
                    froze_name: n.data.froze_name,
                    usable_name: n.data.usable_name,
                    redpack_enable: n.data.redpack_enable,
                    activation_record: n.data.activation_record,
                    poster_center_show: n.data.poster_center_show,
                    love_poster_name: n.data.love_poster_name,
                    love_cycle_reward: n.data.love_cycle_reward,
                    speed_pool_enable: n.data.speed_pool_enable,
                    change_integral: n.data.change_integral || {},
                    active_froze: n.data.active_froze,
                    show_usable: n.data.show_usable
                }), n.data.love_queue && e.setData({
                    "love_queue.credit_validity_at": a.getTimeDifference(JSON.parse(JSON.stringify(n.data.love_queue.credit_validity_at))),
                    love_queue: void 0 !== n.data.love_queue ? JSON.parse(JSON.stringify(n.data.love_queue)) : "",
                    love_queue_length: void 0 !== n.data.love_queue ? String(n.data.love_queue.queue_credit).length : 0
                }), wx.setNavigationBarTitle({
                    title: t.data.title
                }), wx.setStorageSync("love_name", t.data.love_name), 1 == t.data.trading_status && t.getLove()) : wx.showToast({
                    title: n.msg,
                    icon: "none",
                    duration: 2e3
                });
            },
            fail: function(e) {
                console.log(e);
            }
        });
    },
    gotoPage: function(e) {
        var a = e.target.dataset.url || e.currentTarget.dataset.url;
        if ("loveWithdrawals" !== a || 1 != this.data.withdrawData.disable) {
            if ("LoveRecharge" == a && this.data.ios_virtual_pay) return wx.showModal({
                title: "提示",
                content: "十分抱歉，由于相关规定，你暂时无法在这里充值！",
                confirmText: "知道了",
                showCancel: !1,
                success: function(e) {
                    e.confirm && console.log(e);
                }
            }), !1;
            if ("love_trading_sell" != a) if ("loveCycleReceive" != a) {
                if ("LoveSpeedLease" == a) return wx.navigateTo({
                    url: "/packageB/member/love/".concat(a, "/").concat(a, "?love_name=").concat(this.data.love_name)
                });
                if ("love_active_froze" == a) return wx.navigateTo({
                    url: "/packageB/member/love/".concat(a, "/").concat(a, "?froze_name=").concat(this.data.froze_name, "&pointKey=").concat(this.data.pointKey)
                });
                if ("toIntegral" == a) {
                    var t = new Date().getTime(), o = this.data.change_integral, n = o.start, s = o.end, i = new Date(n.replace(/-/g, "/")).getTime(), r = new Date(s.replace(/-/g, "/")).getTime();
                    if (i > t || t > r) return void wx.showToast({
                        title: "请在".concat(n, "到").concat(s, "转换"),
                        icon: "none"
                    });
                }
                wx.navigateTo({
                    url: "/packageB/member/love/" + a + "/" + a
                });
            } else wx.navigateTo({
                url: "/packageB/member/love/" + a + "/" + a + "?love_name=" + this.data.love_name
            }); else wx.navigateTo({
                url: "/packageA/member/balance/transformLoveV/transformLoveV?name=transformLoveV"
            });
        } else wx.showToast({
            icon: "none",
            title: this.data.withdrawData.day_msg
        });
    },
    getLove: function() {
        var e = this, t = this, o = a.getNetAddresss("plugin.love.Frontend.Modules.Trading.Controllers.trading.get-sell-love");
        a._postNetWork({
            url: o,
            success: function(o) {
                if (1 === o.data.result) {
                    null == o.data.data.love ? e.setData({
                        usables: 0,
                        poundage: o.data.data.set.poundage,
                        trading_limit: o.data.data.set.trading_limit,
                        trading_fold: o.data.data.set.trading_fold
                    }) : e.setData({
                        usables: o.data.data.love.usable,
                        poundage: o.data.data.set.poundage,
                        trading_limit: o.data.data.set.trading_limit,
                        trading_fold: o.data.data.set.trading_fold
                    });
                    try {
                        a._isTextEmpty(o.data.data.set.trading_fetter) || t.setData({
                            trading_fetter: o.data.data.set.trading_fetter
                        });
                    } catch (e) {
                        console.log(e);
                    }
                } else wx.showToast({
                    title: o.data.msg,
                    icon: "none"
                });
            },
            fail: function(e) {
                console.log(e);
            }
        });
    },
    saleBalance: function() {
        var e = this;
        if (this.data.sell_value) {
            var t = a.getNetAddresss("plugin.love.Frontend.Modules.Trading.Controllers.trading.save-sell-love");
            t += "&amount=" + this.data.sell_value, a._postNetWork({
                url: t,
                success: function(a) {
                    1 === a.data.result ? (wx.showToast({
                        title: a.data.msg,
                        icon: "none"
                    }), e.setData({
                        sell_value: ""
                    }), setTimeout(function() {
                        e.getLove(), e.onClickLeft();
                    }, 1e3)) : wx.showToast({
                        title: a.data.msg,
                        icon: "none"
                    });
                },
                fail: function(e) {
                    console.log(e);
                }
            });
        } else wx.showToast({
            title: "请输入您要出售的数额",
            icon: "none"
        });
    },
    onChange: function(e) {
        this.setData({
            sell_value: e.detail
        });
    },
    onClickLeft: function() {
        this.setData({
            show: !1
        }), wx.setNavigationBarTitle({
            title: this.data.title
        });
    },
    onClickRight: function() {
        wx.navigateTo({
            url: "/packageB/member/love/love_list/love_list"
        });
    }
});